package com.zjmzxfzhl.modules.flowable.controller;

import com.zjmzxfzhl.modules.flowable.entity.FlowableForm;
import com.zjmzxfzhl.modules.flowable.mapper.FlowableFormMapper;
import com.zjmzxfzhl.modules.flowable.service.ClientService;
import com.zjmzxfzhl.modules.flowable.util.ProjectFileUtils;
import io.dshubs.archives.dto.ArchiveBaseCategoryDto;
import io.dshubs.archives.feign.ArchivesFeignClient;
import io.dshubs.commons.tools.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.alibaba.fastjson.JSON.parseArray;
import static com.alibaba.fastjson.JSON.parseObject;

/**
 * @author tan 2021/9/6
 **/
@Slf4j
@RestController
@RequestMapping("/client")
public class ClientController {


    @Autowired
    private ClientService clientService;

    @GetMapping("/class-field")
    public Result<List<Map<String,String>>> getClassField(Long id){
        return new Result<List<Map<String,String>>>().ok(clientService.getClassField(id));
    }


    @GetMapping("/template/download")
    @ApiOperation("下载自定义表单模板")
    public void exportExcelData(HttpServletResponse response, Long id) throws Exception {
        ProjectFileUtils.dynamicTemplateDownload(response, clientService.getClassField(id),"批量导入模板.xls");
    }


}
